/*dI7NGtwwut/X3kMNlFpmlfN9YA8xqA0b81JVnE8a5pUxcg1zIBPiZ/sNPgiv57o2*/
import { renderSelectField,renderMetaforRef } from '../publicMethods/pubUtils';

/**
 * 应付核销，本方核销对象编辑后事件
 * @param {*} props 
 * @param {*} cytjCode 
 * @param {*} bfCode 
 * @param {*} dfCode 
 */
function jf_hxdxCBox_AfterEvent(that, props, value, cytjCode, bfCode, dfCode) {
    let meta = props.meta.getMeta()
    if (value.value == 'kh') {
        renderSelectField(that, props, bfCode, 'jfBillTypeBox', ['khys', 'gysfk'])
        renderSelectField(that, props, dfCode, 'df_hxdxCBox', ['kh', 'gys'])
        renderSelectField(that, props, dfCode, 'dfBillTypeBox', ['khsk', 'gysyf'])

        props.form.setFormItemsValue(cytjCode, { 'jf_dxmcRef': { value: null, display: null } });
        props.form.setFormItemsValue(cytjCode, { 'df_dxmcRef': { value: null, display: null } });
    }
    if (value.value == 'gys' || value.value == 'bm' || value.value == 'ywy') {
        if (value.value == 'gys') {
            renderSelectField(that, props, bfCode, 'jfBillTypeBox', ['khys', 'gysfk'])
            renderSelectField(that, props, dfCode, 'df_hxdxCBox', ['kh', 'gys', 'bm', 'ywy'])
            renderSelectField(that, props, dfCode, 'dfBillTypeBox', ['khsk', 'gysyf'])
        } else if (value.value == 'bm') {
            renderSelectField(that, props, bfCode, 'jfBillTypeBox', ['gysfk'])
            renderSelectField(that, props, dfCode, 'df_hxdxCBox', ['kh', 'gys', 'bm', 'ywy'])
            renderSelectField(that, props, dfCode, 'dfBillTypeBox', ['gysyf'])
        } else if (value.value == 'ywy') {
            renderSelectField(that, props, bfCode, 'jfBillTypeBox', ['gysfk'])
            renderSelectField(that, props, dfCode, 'df_hxdxCBox', ['kh', 'gys', 'bm', 'ywy'])
            renderSelectField(that, props, dfCode, 'dfBillTypeBox', ['gysyf'])
        }
        props.form.setFormItemsValue(cytjCode, { 'jf_dxmcRef': { value: null, display: null } });
        props.form.setFormItemsValue(cytjCode, { 'df_dxmcRef': { value: null, display: null } });
    }
    let jfhxdx = props.form.getFormItemsValue(cytjCode, 'jf_hxdxCBox').value
    let dfhxdx = props.form.getFormItemsValue(cytjCode, 'df_hxdxCBox').value

    if (jfhxdx) {
        renderMetaforRef(that, props, meta, value, cytjCode, bfCode, null, jfhxdx);
    }
    if (dfhxdx) {
        renderMetaforRef(that, props, meta, value, cytjCode, dfCode, dfhxdx, null);
    }
    props.meta.setMeta(meta);
    //重新渲染本方对象名称
    props.renderItem('form', bfCode, 'jf_dxmcRef', null);
    props.renderItem('form', dfCode, 'df_dxmcRef', null);
}

/**
 * 应付核销，本方单据类型编辑后事件
 * @param {*} props 
 * @param {*} cytjCode 
 * @param {*} bfCode 
 * @param {*} dfCode 
 */
function jfBillTypeBox_AfterEvent(that, props, value, cytjCode, bfCode, dfCode) {
    let jfhxdx = props.form.getFormItemsValue(cytjCode, 'jf_hxdxCBox').value
    let dfhxdx = props.form.getFormItemsValue(cytjCode, 'df_hxdxCBox').value
    let meta = props.meta.getMeta()
    if (jfhxdx == 'kh') {
        if (value.value == 'gysfk') {
            if (dfhxdx == 'kh') {
                renderSelectField(that, props, dfCode, 'dfBillTypeBox', ['khsk', 'gysyf'])
            } else if (dfhxdx == 'gys') {

                renderSelectField(that, props, dfCode, 'dfBillTypeBox', ['khsk'])
            }
        } else if (value.value == 'khys') {
            if (dfhxdx == 'kh') {
                renderSelectField(that, props, dfCode, 'dfBillTypeBox', ['gysyf'])
            } else if (dfhxdx == 'gys') {
                renderSelectField(that, props, dfCode, 'dfBillTypeBox', ['gysyf'])
            }
        }
    } else if (jfhxdx == 'gys') {
        if (value.value == 'gysfk') {
            if (dfhxdx == 'kh') {
                renderSelectField(that, props, dfCode, 'dfBillTypeBox', ['khsk'])
            } else if (dfhxdx == 'gys') {
                renderSelectField(that, props, dfCode, 'dfBillTypeBox', ['khsk', 'gysyf'])
            } else if (dfhxdx == 'bm') {
                renderSelectField(that, props, dfCode, 'dfBillTypeBox', ['gysyf'])
            } else if (dfhxdx == 'ywy') {
                renderSelectField(that, props, dfCode, 'dfBillTypeBox', ['gysyf'])
            }
        } else if (value.value == 'khys') {
            if (dfhxdx == 'kh') {
                renderSelectField(that, props, dfCode, 'dfBillTypeBox', ['gysyf'])
            } else if (dfhxdx == 'gys') {
                renderSelectField(that, props, dfCode, 'df_hxdxCBox', ['kh', 'gys'])
                renderSelectField(that, props, dfCode, 'dfBillTypeBox', ['gysyf'])
            }
        }
    } else if (jfhxdx == 'bm') {
        if (value.value == 'gysfk') {
            if (dfhxdx == 'gys') {
                renderSelectField(that, props, dfCode, 'dfBillTypeBox', ['gysyf'])
            }
        }
    } else if (jfhxdx == 'ywy') {
        if (value.value == 'gysfk') {
            if (dfhxdx == 'gys') {
                renderSelectField(that, props, dfCode, 'dfBillTypeBox', ['gysyf'])
            }
        }
    }
    //渲染之后再次渲染参照
    let jfhxdx2 = props.form.getFormItemsValue(cytjCode, 'jf_hxdxCBox').value
    let dfhxdx2 = props.form.getFormItemsValue(cytjCode, 'df_hxdxCBox').value
    if(jfhxdx2){
        renderMetaforRef(that, props, meta, value, cytjCode, bfCode, null,jfhxdx2);
    }
    if(dfhxdx2){
        renderMetaforRef(that, props, meta, value, cytjCode, dfCode,dfhxdx2,null); 
    }
    props.meta.setMeta(meta);
}

/**
 * 应付核销，对方核销对象编辑后事件
 * @param {*} props 
 * @param {*} cytjCode 
 * @param {*} bfCode 
 * @param {*} dfCode 
 */
function df_hxdxCBox_AfterEvent(that, props, value, cytjCode, bfCode, dfCode) {
    let jfhxdx = props.form.getFormItemsValue(cytjCode, 'jf_hxdxCBox').value
    let jfBilltype = props.form.getFormItemsValue(cytjCode, 'jfBillTypeBox').value
    let meta = props.meta.getMeta()
    if (value.value == 'kh') {
        if (jfhxdx == 'kh' && jfBilltype == 'khys') {
            renderSelectField(that, props, dfCode, 'dfBillTypeBox', ['gysyf'])
        } else if (jfhxdx == 'kh' && jfBilltype == 'gysfk') {
            renderSelectField(that, props, dfCode, 'dfBillTypeBox', ['khsk', 'gysyf'])
        } else if (jfhxdx == 'gys' && jfBilltype == 'khys') {
            renderSelectField(that, props, dfCode, 'dfBillTypeBox', ['gysyf'])
        } else if (jfhxdx == 'gys' && jfBilltype == 'gysfk') {
            renderSelectField(that, props, dfCode, 'dfBillTypeBox', ['khsk'])
        } else {
            // props.form.setFormItemsValue(cytjCode, { 'jf_hxdxCBox': { value: 'gys', display: that.state.json['verificationsheet-000001'] } });/* 国际化处理： 供应商*/
            // props.form.setFormItemsDisabled(cytjCode, { jf_hxdxCBox: true });
        }
        props.form.setFormItemsValue(cytjCode, { 'jf_dxmcRef': { value: null, display: null } });
        props.form.setFormItemsValue(cytjCode, { 'df_dxmcRef': { value: null, display: null } });
    }
    if (value.value == 'gys' || value.value == 'bm' || value.value == 'ywy') {
        if (value.value == 'gys') {
            if (jfhxdx == 'kh') {
                if (jfBilltype == 'khys') {
                    renderSelectField(that, props, dfCode, 'dfBillTypeBox', ['gysyf'])
                } else if (jfBilltype == 'gysfk') {
                    renderSelectField(that, props, dfCode, 'dfBillTypeBox', ['khsk'])
                }
            } else if (jfhxdx == 'gys') {
                if (jfBilltype == 'khys') {
                    renderSelectField(that, props, dfCode, 'dfBillTypeBox', ['gysyf'])
                } else if (jfBilltype == 'gysfk') {
                    renderSelectField(that, props, dfCode, 'dfBillTypeBox', ['khsk', 'gysyf'])
                }
            } else if (jfhxdx == 'bm') {
                if (jfBilltype == 'gysfk') {
                    renderSelectField(that, props, dfCode, 'dfBillTypeBox', ['gysyf'])
                }
            } else if (jfhxdx == 'ywy') {
                if (jfBilltype == 'gysfk') {
                    renderSelectField(that, props, dfCode, 'dfBillTypeBox', ['gysyf'])
                }
            }
        } else if (value.value == 'bm') {
            if (jfhxdx == 'gys' || jfhxdx == 'bm' || jfhxdx == 'ywy') {
                if (jfBilltype == 'gysfk') {
                    renderSelectField(that, props, dfCode, 'dfBillTypeBox', ['gysyf'])
                }
            }
        } else if (value.value == 'ywy') {
            if (jfhxdx == 'gys' || jfhxdx == 'bm' || jfhxdx == 'ywy') {
                if (jfBilltype == 'gysfk') {
                    renderSelectField(that, props, dfCode, 'dfBillTypeBox', ['gysyf'])
                }
            }
        }
        props.form.setFormItemsValue(cytjCode, { 'jf_dxmcRef': { value: null, display: null } });
        props.form.setFormItemsValue(cytjCode, { 'df_dxmcRef': { value: null, display: null } });
    }
    let jfhxdx2 = props.form.getFormItemsValue(cytjCode, 'jf_hxdxCBox').value
    let dfhxdx2 = props.form.getFormItemsValue(cytjCode, 'df_hxdxCBox').value

    if (jfhxdx2) {
        renderMetaforRef(that, props, meta, value, cytjCode, bfCode, null, jfhxdx2);
    }
    if (dfhxdx2) {
        renderMetaforRef(that, props, meta, value, cytjCode, dfCode, dfhxdx2, null);
    }
    props.meta.setMeta(meta);
    //重新渲染对方对象名称
    props.renderItem('form', bfCode, 'jf_dxmcRef', null);
    props.renderItem('form', dfCode, 'df_dxmcRef', null);
}

export { jf_hxdxCBox_AfterEvent, jfBillTypeBox_AfterEvent, df_hxdxCBox_AfterEvent }
/*dI7NGtwwut/X3kMNlFpmlfN9YA8xqA0b81JVnE8a5pUxcg1zIBPiZ/sNPgiv57o2*/